<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>任务管理</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

    <div class="comm_crub">
        <span class="now_crub">任务列表</span>
    </div>

    <div class="comm_content">

            <div  class="search-box">
                <div style="position:relative">
                    <form id="searchForm">
                        <table>
                            <tr>
                                <td>
                                    <span>
                                        任务组名称：
                                        <select id="taskGroupId" name="taskGroupId" style="width:120px;">
                                            <option value="0">请选择</option>
                                            <option value="1">系统任务</option>
                                            <option value="2">B2C商城</option>
                                            <option value="3">CRM</option>
                                            <option value="4">微电汇</option>
                                            <option value="5">xShop</option>
                                        </select>
                                    </span>
                                    <span><input type="button" class="btn" value="查询" onclick="assignment.search();"></span>
                                    <span><input type="reset" class="btn" value="重置"></span>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/project/assignment.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 100, align: 'center'},
            {display: "任务名称", name : "taskId" , width : 150 , sortable : true },
            {display: "任务组", width : 100},
            {display: "任务文件名", width : 180},
            {display: "任务脚本", width : 100},
            {display: "任务执行时间", width : 100}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "assignment.edit"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "assignment.del.check"}
        ],
        sortname: "taskId",
        sortorder: "ASC",
        usepager: true,
        rp: 10,
        useRp: true,
        query: '',
        showTableToggleBtn: true
    });

    var assignment = {

        search: function() {
            var dt = $("#searchForm").serializeArray();
            $("#flex").flexOptions({newp: 1, params: dt}).flexReload();
        },

        edit: function(taskId) {

            if (taskId) {
                E.open("/quanliadmin/app/project/assignment.pscript?operFlg=2&taskId=" + taskId);
            } else {
                E.open("/quanliadmin/app/project/assignment.pscript?operFlg=2");
            }

        },

        del: {

            p_array: "",

            check: function() {

                if ($(".trSelected",flex).length == 0) {
                    E.alert("请选择要删除的权限");
                } else {
                    var assignment_array = new Array();
                    //循环选中的行
                    $(".trSelected",flex).each(function(k, v){
                        assignment_array.push($(v).attr("id").substr(3));
                    });
                    this.p_array = assignment_array;
                    //弹出确认层
//                    E.confirm("您确认要删除选择的任务吗？", "assignment.del.execute");
                }

            },

            execute: function() {
                E.loadding.open("正在删除任务，请稍候...");
                E.ajax_get({
                    url: "/invokingAjax-backend/project/assignment.ajax?operFlg=3",
                    data: {
                        p_array: this.p_array
                    },
                    call: "assignment.del.result"
                });
            },

            result: function( o ) {

                E.loadding.close();
                if (o.code == 200) {

                    E.alert(o.message, 2, "assignment.load");

                } else {

                    E.alert(o.message);

                }
            }

        },

        load: function() {
            $("#flex").flexReload();
        }

    };
</script>
</body>
</html>